<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>前后端的调用</title>
		<script src="../js/axios.js"></script>
	</head>
	<body>
		<h1>前后端的调用</h1>
		<script>
		/*get方式一
		url1: http://localhost:8090/axios/getUserById?id=1
		*/
	   let url1 = "http://localhost:8090/axios/getUserById?id=1"
	   axios.get(url1).then(Promise=>{
		   console.log(Promise.data)
	   })
	   
	   /*get方式二
			url2: http://localhost:8090/axios/user/女/18
			原因：restful越来越受欢迎，则拼接restful拼接变得繁琐
			模板字符串：
			语法：一对反引号``
			取值：${key}
			优势：保留代码的格式
	   */
	  let sex2 = prompt("请输入性别:")
	  let age2 = prompt("请输入年龄:")
	  // let url2 = "http://localhost:8090/axios/user/"+sex2+"/"+age2
	  let url2 = `http://localhost:8090/axios/user/${sex2}/${age2}`
	  axios.get(url2).then(Promise=>{
		  console.log(Promise.data)
	  })
	  
	  /*get方式三
	  			url3: http://localhost:8090/axios/getuser
	  			参数语法：{} 
				关键字key(固定写法) {params:对象} 
	  */
	 let url3:"http://localhost:8090/axios/getuser"
	 let user = {
		 name:'王昭君',
		 sex:'女',
		 age:19
	 }
	 axios.get(url3,{params:user}).
		</script>
	</body>
</html>
